package comparable;

/*
 * 如果排序逻辑是类固有的部分
 */
public class Person implements Comparable<Person> {
    String name;
    int age;

    public Person(String name, int age) {
        super();
        this.name = name;
        this.age = age;
    }

    public Person() {
        super();
    }

    @Override
    public int compareTo(Person o) {

        return this.age - o.age;
    }

    @Override
    public String toString() {
        return "Person [name=" + name + ", age=" + age + "]";
    }

}
